<?
class AdminSys extends YYBDB
{
	var $UserName;
	var $PassWord;
	var $Info;
	var $Rule;
	var $GetID;
	
	
	function Class_Terminate()
	{
		unset($this);
	} 
	//用户登陆
	function Login()
	{
	
		global $SystemConest;
		$sqlrs="Select * From ".$SystemConest[7]."sysadmin Where sysadmin1='" .$this->UserName . "' And sysadmin2='". $this->PassWord . "'";
		$rsc=$this->db_query($sqlrs);
		$num=$this->db_num_rows($rsc);
		$rs=$this->db_fetch_array($rsc);
		if($num>0)
		{
			$Login=$rs;
			
			echo "用户登陆成功！";
		}
		else
		{
			echo "用户名或密码错误！";	
			
		}
		while($rs=$this->db_fetch_array($rsc))
		{
			echo "用户登陆成功！";
			$Login=NULL;
		} 
		$_SESSION["Login"]=$Login;
	} 
	//检测用户名
	function CheckUserName()
	{
		if($this->GetID()==0)
		{
		    return 0;
		}
		else
		{
			return 1;
		}
	}
	
	//注销
	function OutLogin()
	{
	   unset($_SESSION["Login"]);
	}
	
	//修改密码
	function UpDatePassWord()
	{
	   
	  	$this->Info[0]=$this->GetID();
	    $this->Info[1]=$UserName;
		$this->Info[2]=$PassWord;
		
	    $this->ArrFields=$this->Info;
        $this->Update();
	}
	
	
	//用户注册
	//0-注册成功
	//1-用户名重复
	
	function Reg()
	{
	    if($this->GetID()==0)
		{ 
			
			$this->ArrFields=$this->Info;
			$this->Add();
			return 0;
		}	
		else
		{
		   return 1;
		}
	}
	
	//修改用户信息
	function UpDateInfo()
	{
	   $this->UpDatePassWord();
	}
	
	//删除用户
	function Dalete()
	{
	    $this->Info[0]=$this->GetID();
	    $this->ArrFields=$this->Info;
        $this->Delete();
	}
	
	//获取ID
	function GetID()
	{
		global $SystemConest;
		$sqlrs="Select * From ".$SystemConest[7]."sysadmin where sysadmin1='" . $this->UserName . "'";
		$rsc=$this->db_query($sqlrs);
		$rs=$this->db_fetch_array($rsc);
		$num=$this->db_num_rows($rsc);
		if($num>0)
		{
			return $rs[0];
		}
		else
		{
			return 0;
		}
		
	}
}
?>